package com.lonely.fx;

import javafx.application.Application;
import javafx.geometry.HPos;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import javafx.geometry.VPos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Separator;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

/**
 * @date: 2022-07-20 16:59
 * @author: ztkj-hzb
 * @description: 分隔符组件设置
 **/
public class SeparatorSettingMain extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    /**
     *
     */
    @Override
    public void start(Stage primaryStage) throws Exception {

        Group group = new Group();

        HBox hBox = new HBox();
        hBox.setPrefHeight(50);
        hBox.setStyle("-fx-background-color: pink");
        //hBox.setSpacing(20);
        //hBox.setAlignment(Pos.CENTER);

        //创建分隔符
        Separator separator = new Separator();
        //separator.setStyle("-fx-background-color: blue");

        //设置分隔符方向，默认是水平
        separator.setOrientation(Orientation.VERTICAL);

        separator.setPrefSize(300,300);

        //设置水平居中
        //separator.setHalignment(HPos.CENTER);

        //设置纵向居中，默认是TOP
        separator.setValignment(VPos.CENTER);

        hBox.getChildren().addAll(new Button("篮球"),new Button("足球"),
                separator,
                new Button("男装"),new Button("女装"));

        group.getChildren().add(hBox);
        primaryStage.setScene(new Scene(group));
        primaryStage.setWidth(600);
        primaryStage.setHeight(500);
        primaryStage.show();
    }
}
